const fs = require("fs");
const http = require("http");
const path = require("path");

http.createServer((req, res)=>{
    var urlStr = req.url;
    var filePath = path.join(__dirname,"/test.html");
    var imgPath = path.join(__dirname, "/bg1.jpg");
    if(urlStr=="/"){
        var fileContent = fs.readFileSync(filePath);
        res.writeHead(200, {"Content-type": "test.html; charset=utf8"});
        res.write(fileContent);
        res.end();
    }else if(urlStr == "/bg1.jpg"){
        var imgContent = fs.readFileSync(imgPath);
        res.writeHead(200, {"Content-type": "image/jpg"});
        res.write(imgContent);
        res.end();
    }
}).listen(8083)